#ifndef _BUOLA_SCENE_IMPORT_COBJPARSER_H_
#define _BUOLA_SCENE_IMPORT_COBJPARSER_H_

#include <buola/scene.h>
#include <buola/io/curi.h>
#include <buola/mat/transformations.h>

namespace buola { namespace scene { namespace import {

class COBJParser
{
    struct SGroup
    {
        std::string mName;
        std::vector<int> mPolygons;
    };

public:
    COBJParser();
    ~COBJParser();

private:
    void ParseV(const std::vector<std::string> &pV);
    void ParseF(const std::vector<std::string> &pV);
    void ParseG(const std::vector<std::string> &pV);
    void ParseS(const std::vector<std::string> &pV);
    void ParseUsemtl(const std::vector<std::string> &pV);

public:
    PMesh Parse(const io::CURI &pURI,double pScale);
    
    std::vector<mat::CVec3d> mPosition;
    std::vector<mat::CVec3d> mNormal;
    std::vector<mat::CVec3d> mTexCoord;

    struct
    {
        std::vector<int> mPosition;
        std::vector<int> mNormal;
        std::vector<int> mTexCoord;
    } mVertices;

    std::vector<int> mPolygons;

    std::vector<SGroup*> mGroups;
    std::vector<SGroup*> mSmoothGroups;
    std::vector<SGroup*> mMaterials;

    SGroup *mCurGroup;
    SGroup *mCurSmoothGroup;
    SGroup *mCurMaterial;
};

/*namespace import*/ } /*namespace scene*/ } /*namespace buola*/ }

#endif